package com.ThreadDemo;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: FENGYiMing
 * @Date: 2024/03/29/18:25
 * @Description:
 */
public class Thead01 {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.start(); //启动线程

        System.out.println("asdasdas");

        Dog dog = new Dog();
        Thread thread = new Thread(dog);
        Thread thread1 = new Thread(dog);
        thread.start();
        thread1.start();

    }
}

class Cat extends Thread {
    @Override
    public void run() {
        int timer = 0;
        do {
            timer++;
            System.out.println("我是一只小猫猫");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        } while (timer != 8);

    }
}

class Dog implements Runnable {

    @Override
    public void run() {
        int timer = 0;
        do {
            timer++;
            System.out.println("我是一只小狗");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        } while (timer != 3);
    }
}
